import Koa from "koa";
import router from "./router/index.js";
import bodyParser from "koa-bodyparser";
import { regTemplate } from "./template/index.js";
import serve from "koa-static";
import { staticVisit } from "./router/utils.js";

const app = new Koa(); //实例化koa

app.use(bodyParser()); //解析json对象

app.use(regTemplate()); //注册模板引擎

app.use(serve(staticVisit())); //使用静态资源

app.use(router); //挂载路由

//监听端口
app.listen(5666, () => {
  console.log("服务运行地址:http://localhost:5666");
});
